package com.ieslab.powergrid.demosvr.utils;


import com.ieslab.powergrid.demosvr.entity.Person;
import com.ieslab.powergrid.demosvr.entity.TestEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class TestEventListener implements ApplicationListener<TestEvent> {
    @Override
    public void onApplicationEvent(TestEvent testEvent) {
        // 把事件中的信息获取到
        Person person = testEvent.getPerson();
        // 处理事件，实际项目中可以通知别的微服务或者处理其他逻辑等
        log.info("用户名：" + person.getFirstName());
        log.info("城市：" + person.getCity());

    }
}
